<template>
	<view>
		<view class="iconfont">
			<uni-segmented-control :values="items" style-type="text" active-color='#e64340' @clickItem="show" />
		</view>
		
		<hr class="part"/>
		<view v-show="inv_se == 0">
			<view class="no-content" v-if="paperList.length==null||paperList.length===0">
				<text>已将到底了</text>
			</view>
			<view v-for="(item, index) in paperList" :key="index">
				<uni-collapse class="warp">
					<uni-collapse-item :show-animation="true" :title="item.name">
						<text class="content" v-if="item.teaPaperId!==null && item.teaPaperId!==''">
							<text class="iconfont" style="color: #e64340;" >&#xe7cb;</text>论文编号：{{item.teaPaperId}}
						</text>
						<text class="content" v-if="item.name!==null && item.name!==''">
							<text class="iconfont" style="color: #268de6;">&#xe8ce;</text>论文名：{{item.name}}
						</text>
						<text class="content" v-if="item.firstAuthor!==null && item.firstAuthor!==''">
							<text class="iconfont" style="color: #49e62e;">&#xe669;</text>第一作者：{{item.firstAuthor}}
						</text>
						<text class="content" v-if="item.secondAuthor!==null && item.secondAuthor!==''">
							<text class="iconfont" style="color: #ff55ff;">&#xe669;</text>第二作者：{{item.secondAuthor}}
						</text>
						<text class="content" v-if="item.thirdAuthor!==null && item.thirdAuthor!==''">
							<text class="iconfont" style="color: #e616e3;" >&#xe669;</text>第三作者：{{item.thirdAuthor}}
						</text>
						<text class="content" v-if="item.impactFactor!==null && item.impactFactor!==''">
							<text class="iconfont" style="color: #e6e61e;">&#xe651;</text>影响因子：{{item.impactFactor}}
						</text>
						<text class="content" v-if="item.cited!==null && item.cited!==''">
							<text class="iconfont" style="color: #ffaa00;">&#xe696;</text>被引次数：{{item.cited}}
						</text>
						<text class="content" v-if="item.con!==null && item.con!==''">
							<text class="iconfont" style="color: #7350e6;">&#xe807;</text>描述：{{item.con}}
						</text>
						<text class="content" v-if="item.publishedTime!==null && item.publishedTime!==''">
							<text class="iconfont" style="color: #e64340;">&#xe62a;</text>发表时间：{{item.publishedTime}}
						</text>
					</uni-collapse-item>
				</uni-collapse>
			</view>
		</view>
		<view v-show="inv_se == 1">
			<view class="no-content" v-if="monographList.length==null||monographList.length===0">
				<text>已将到底了</text>
			</view>
			<view v-for="(item, index) in monographList" :key="index">
				<uni-collapse class="warp">
					<uni-collapse-item :show-animation="true" :title="item.name">
						<text class="content" v-if="item.teaTreatiseId!==null && item.teaTreatiseId!==''">
							<text class="iconfont" style="color: #e64340;" >&#xe7cb;</text>专著编号：{{item.teaTreatiseId}}
						</text>
						<text class="content" v-if="item.name!==null && item.name!==''">
							<text class="iconfont" style="color: #49e62e;">&#xe62e;</text>专著名：{{item.name}}
						</text>
						<text class="content" v-if="item.firstAuthor!==null && item.firstAuthor!==''">
							<text class="iconfont" style="color: #268de6;">&#xe669;</text>第一作者：{{item.firstAuthor}}
						</text>
						<text class="content" v-if="item.secondAuthor!==null && item.secondAuthor!==''">
							<text class="iconfont" style="color: #7350e6;">&#xe669;</text>第二作者：{{item.secondAuthor}}
						</text>
						<text class="content" v-if="item.third_author!==null && item.third_author!==''">
							<text class="iconfont" style="color: #ff55ff;" >&#xe669;</text>第三作者：{{item.third_author}}
						</text>
						<text class="content" v-if="item.con!==null && item.con!==''">
							<text class="iconfont" style="color: #e6e61e;">&#xe807;</text>描述：{{item.con}}
						</text>
						<text class="content" v-if="item.publishedTime!==null && item.publishedTime!==''">
							<text class="iconfont" >&#xe62a;</text>发表时间：{{item.publishedTime}}
						</text>
					</uni-collapse-item>
				</uni-collapse>
			</view>
		</view>
		<view v-show="inv_se == 2">
			<view class="no-content" v-if="projectList.length==null||projectList.length===0">
				<text>已将到底了</text>
			</view>
			<view v-for="(item, index) in projectList" :key="index">
				<uni-collapse class="warp">
					<uni-collapse-item :show-animation="true" :title="item.name">
						<text class="content" v-if="item.teaProjectId!==null && item.teaProjectId!==''">
							<text class="iconfont" style="color: #e64340;" >&#xe7cb;</text>项目编号：{{item.teaProjectId}}
						</text>
						<text class="content" v-if="item.name!==null && item.name!==''">
							<text class="iconfont" style="color: #268de6;">&#xe6eb;</text>项目名：{{item.name}}
						</text>
						<text class="content" v-if="item.startTime!==null && item.startTime!==''">
							<text class="iconfont" style="color: #49e62e;">&#xe62a;</text>开始时间：{{item.startTime}}
						</text>
						<text class="content" v-if="item.endTime!==null && item.endTime!==''">
							<text class="iconfont" style="color: #7350e6;">&#xe62a;</text>结束时间：{{item.endTime}}
						</text>
						<text class="content" v-if="item.con!==null && item.con!==''">
							<text class="iconfont" style="color: #ff55ff;">&#xe807;</text>描述：{{item.con}}
						</text>
						<text class="content" v-if="item.source!==null && item.source!==''">
							<text class="iconfont" style="color: #e6e61e;">&#xe6d9;</text>来源：{{item.source}}
						</text>
						<text class="content" v-if="item.tier!==null && item.tier!==''">
							<text class="iconfont" style="color: #c995e6;">&#xe62c;</text>项目级别： <text v-if="item.tier==0">国家级</text><text v-else>省级</text>
						</text>
						<text class="content" v-if="item.leader!==null && item.leader!==''">
							<text class="iconfont" style="color: #8e36e6;">&#xe62f;</text>是否是立项人： <text v-if="item.leader==1">是</text><text v-else>否</text>
						</text>
					</uni-collapse-item>
				</uni-collapse>
			</view>
		</view>
		<view v-show="inv_se == 3">
			<view class="no-content" v-if="awardList.length==null||awardList.length===0">
				<text>已将到底了</text>
			</view>
			<view v-for="(item, index) in awardList" :key="index">
				<uni-collapse class="warp">
					<uni-collapse-item :show-animation="true" :title="item.name">
						<text class="content" v-if="item.teaAwardId!==null && item.teaAwardId!==''">
							<text class="iconfont" style="color: #e64340;" >&#xe7cb;</text>奖励编号：{{item.teaAwardId}}
						</text>
						<text class="content" v-if="item.name!==null && item.name!==''">
							<text class="iconfont" style="color: #268de6;">&#xe7fc;</text>奖励名：{{item.name}}
						</text>
						<text class="content" v-if="item.con!==null && item.con!==''">
							<text class="iconfont" style="color: #7350e6;">&#xe807;</text>描述：{{item.con}}
						</text>
						<text class="content" v-if="item.getTime!==null && item.getTime!==''">
							<text class="iconfont" style="color: #ff55ff;">&#xe62a;</text>获得日期：{{item.getTime}}
						</text>
						<text class="content" v-if="item.source!==null && item.source!==''">
							<text class="iconfont" style="color: #49e62e;">&#xe6d9;</text>来源：{{item.source}}
						</text>
					</uni-collapse-item>
				</uni-collapse>
			</view>
		</view>
		<view v-show="inv_se == 4">
			<view class="no-content" v-if="patentList.length==null||patentList.length===0">
				<text>已将到底了</text>
			</view>
			<view v-for="(item, index) in patentList" :key="index">
				<uni-collapse class="warp">
					<uni-collapse-item :show-animation="true" :title="item.name">
						<text class="content" v-if="item.teaPatentId!==null && item.teaPatentId!==''">
							<text class="iconfont" style="color: #e64340;" >&#xe7cb;</text>专利编号：{{item.teaPatentId}}
						</text>
						<text class="content" v-if="item.name!==null && item.name!==''">
							<text class="iconfont" style="color: #268de6;">&#xe660;</text>专利名：{{item.name}}
						</text>
						<text class="content" v-if="item.number!==null && item.number!==''">
							<text class="iconfont" >&#xe611;</text>专利号：{{item.number}}
						</text>
						<text class="content" v-if="item.nationality!==null && item.nationality!==''">
							<text class="iconfont" style="color: #49e62e;" >&#xe772;</text>国别：{{item.nationality}}
						</text>
						<text class="content" v-if="item.con!==null && item.con!==''">
							<text class="iconfont" style="color: #ff55ff;">&#xe807;</text>描述：{{item.con}}
						</text>
						<text class="content" v-if="item.publishedTime!==null && item.publishedTime!==''">
							<text class="iconfont" style="color: #e6e61e;">&#xe62a;</text>日期：{{item.publishedTime}}
						</text>
					</uni-collapse-item>
				</uni-collapse>
			</view>
		</view>
	</view>
</template>

<script>
	import * as aRequest from '@/api/tAchievementList.js'
	import {
		uniCollapse,
		uniCollapseItem
	} from '@dcloudio/uni-ui'
	import uniSegmentedControl from '@/components/uni-segmented-control/uni-segmented-control.vue'

	export default {
		components: {
			uniCollapse,
			uniCollapseItem,
			uniSegmentedControl
		},
		data() {
			return {
				items: ['论文', '专著', '项目', '奖励', '专利'],
				inv_se: 0,
				paperList: [],
				monographList: [],
				projectList: [],
				awardList: [],
				patentList: [],
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#ffaa00',
					buttonColor: '#ffaa00'
				},
			}
		},
		methods: {
			show(option) {
				this.inv_se = option.currentIndex
				// this.inv_se = option
				switch (this.inv_se) {
					case 0: //论文
						break
					case 1: //专著
						if (this.monographList.length == 0){
							uni.showLoading()
							aRequest.getTreatiseList({
								tid: getApp().globalData.tid
							}).then(res => {
								// console.log(res)
								this.monographList = res.data.data
								uni.hideLoading()
							}).catch(err => {
								uni.hideLoading()
								uni.showModal({
									content: '请求出错',
									showCancel: false
								})
							})
						}
						break
					case 2: //项目
						if (this.projectList.length == 0){
							uni.showLoading()
							aRequest.getProjectList({
								tid: getApp().globalData.tid
							}).then(res => {
								// console.log(res)
								this.projectList = res.data.data
								uni.hideLoading()
							}).catch(err => {
								uni.hideLoading()
								uni.showModal({
									content: '请求出错',
									showCancel: false
								})
							})
						}
						break
					case 3: //奖励
						if (this.awardList.length == 0){
							uni.showLoading()
							aRequest.getRewardList({
								tid: getApp().globalData.tid
							}).then(res => {
								// console.log(res)
								this.awardList = res.data.data
								uni.hideLoading()
							}).catch(err => {
								uni.hideLoading()
								uni.showModal({
									content: '请求出错',
									showCancel: false
								})
							})
						}
						break
					case 4: //专利
						if (this.patentList.length == 0){
							uni.showLoading()
							aRequest.getPatentList({
								tid: getApp().globalData.tid
							}).then(res => {
								// console.log(res)
								this.patentList = res.data.data
								uni.hideLoading()
							}).catch(err => {
								uni.hideLoading()
								uni.showModal({
									content: '请求出错',
									showCancel: false
								})
							})
						}
						break
				}
			}
		},
		onLoad() {
			uni.showLoading()
			aRequest.getPaperList({
				tid: getApp().globalData.tid
			}).then(res => {
				// console.log(res)
				this.paperList = res.data.data
				uni.hideLoading()
			}).catch(err => {
				uni.hideLoading()
				uni.showModal({
					content: '请求出错',
					showCancel: false
				})
			})
		}
	}
</script>

<style>
	page{
		font-family: '宋体';
	}
	.iconfont {
		font-family: "iconfont" !important;
		font-size: 13px;
		font-style: normal;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
		margin-right: 5px;
	}

	.no-content {
		display: flex;
		height: auto;
		padding: 10px;
		font-size: 14px;
		justify-content: center;
		align-items: center;
		background-color: #f7f7f7;
	}

	.content {
		padding: 15px;
		font-size: 18px;
		line-height: 20px;
		background-color: #fbfbfb;
		color: #666;
		border-bottom: 1px dotted #c8c7cc;
		margin: 0 5px 10px 5px ;
		box-shadow: 5px 5px 3px #d3cfb0;
		border-radius: 5px;
	}
</style>
